package com.ak.demo.controller;

import com.ak.demo.entity.User;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 适用于 qq 的聊天室，聊天室一直存在的，并不是会消失的
 * /queue/<queue name>
 *
 * @author bn
 */
@Controller
public class TopicController {

    @RequestMapping("/topic")
    public String kk(){
        return "topic";
    }


    @Autowired
    private SimpMessagingTemplate template;


    @MessageMapping("/topicAll")
    public void k3(User user){
        template.convertAndSend("/topic/all",JSONObject.toJSONString(user));
    }


}
